package com.foreknow.elmboot.mapper;

import com.foreknow.elmboot.po.DeliveryAddress;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeliveryAddressMapper {


    /**
     * 根据userId 查询地址信息列表
     * @param userId
     * @return
     */
    @Select("select * from deliveryaddress where userId = #{userId} order by daId")
    public List<DeliveryAddress> listDeliveryAddressByUserId(String userId);

    /**
     * 根据daId 查询某一个地址信息
     */
    @Select("select * from deliveryaddress where daId = #{daId}")
    public DeliveryAddress getDeliveryAddressById(Integer daId);

    /**
     * 新增地址
     */
    @Insert("insert into deliveryaddress(contactName,contactSex,contactTel,address,userId) values (#{contactName},#{contactSex},#{contactTel},#{address},#{userId})")
    public int addDeliveryAddress(DeliveryAddress deliveryAddress);

    /**
     * 修改地址
     */
    @Update("update deliveryaddress set contactName=#{contactName},contactSex=#{contactSex},contactTel=#{contactTel},address=#{address} where daId = #{daId}")
    public int updateDeliveryAddress(DeliveryAddress deliveryAddress);


    /**
     * 删除地址
     */
    @Delete("delete from deliveryaddress where daId = #{daId}")
    public int deleteDeliveryAddressById(Integer daId);


}
